<?php

namespace app\admin\model\parts;

use think\Model;
use Throwable;
/**
 * Info
 */
class Info extends Model
{
    // 表名
    protected $name = 'parts_info';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = true;
    protected $updateTime = false;


    public function getPartsCostAttr($value): float
    {
        return (float)$value;
    }

    public function getPartsMoneyAttr($value): float
    {
        return (float)$value;
    }

    public function manufacturerInfo(): \think\model\relation\BelongsTo
    {
        return $this->belongsTo(\app\admin\model\manufacturer\Info::class, 'manufacturer_info_id', 'id');
    }
    // 发起审批
    public function InitiateReview($data):bool
    {
        try {
            $this->model = new \app\admin\model\parts\Approval;
            $res = $this->model->save($data);
            return $res;
        } catch (Throwable $e) {
            return false;
        }
    }
}